<?php
namespace Home\Controller;
use Think\Controller;
class UserController extends Controller {

    public function login($account,$password){
		$User = M('User');
		$User->getByAccount($account);
		if (isset($User->account) && $User->password == $password) {
			$_SESSION['account'] = $User->account;
	        $this->success('登录成功！','../Message/index');
	    } else {
	        $this->error('登录失败！');
	    }
	}

	public function logout(){
		unset($_SESSION['account']);
		$this->display("Index/index");
	}

	public function register(){
		$this->display();
	}
	public function create($account,$password,$repassword){
		$User = M('User');
		$User->getByAccount($account);
		if (isset($User->account) && $User->password == $password||($password !=$repassword)) {
	        $this->error('注册失败！');
	    } else {
	    	$User->create();
	    	$User->add();
	        $this->error('注册成功！','/');
	    }
	}
}